#ifndef _LeetCodePractice_Base_LISTNODE_H_
#define _LeetCodePractice_Base_LISTNODE_H_

#include <iostream>
#include <vector>
#include <assert.h>
using namespace std;

struct ListNode {
	int val;
	ListNode* next;
	ListNode() : val(0), next(nullptr) {}
	ListNode(int x) : val(x), next(nullptr) {}
	ListNode(int x, ListNode* next) : val(x), next(next) {}
};

void PrintListNode(ListNode* pHead)
{
	if (pHead == nullptr)
	{
		cout << endl << endl;
		return;
	}

	ListNode* curr = pHead;
	while (curr != nullptr)
	{
		cout << curr->val << ", ";
		curr = curr->next;
	}
	cout << endl << endl;
}

ListNode* AssignListNode(const vector<int>& src)
{
	if (src.empty())
		return nullptr;
	ListNode* pHead = new ListNode();
	ListNode* curr = pHead;
	for (auto i = 0; i < src.size(); ++i)
	{
		curr->val = src[i];

		if (i < src.size() - 1)
		{
			curr->next = new ListNode();
			assert(curr->next->next == nullptr);
		}

		curr = curr->next;
	}
	return pHead;
}

#endif